import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'
import BottomTab from '../../components/BottomTab'
import VisitDoctorList from '../../components/VisitDoctorList'
import PageTopImage from '../../assets/image/banner.png'
import Login from '../../components/Login/index';
import api from '../../service/api';

import './index.less'

export default class VisitsIndex extends Taro.Component {

  config = {
    navigationBarTitleText: '首页'
  }

  constructor() {
    super(...arguments)
    this.state = {
        DoctorData:[],
        CurrentTab: 0
    }
  }

  componentDidMount() {
    //获取医生列表
    api.get('/inquiry/doctor/list').then(res => {
        this.setState({
          DoctorData: res.data.data
        })
      })
   }

  goBannerDetail(){
    Taro.navigateTo({
      url:`/pages/BannerDetail/index`
    })
  }


  render() {
    return (
      <View className='page'>
        <View className='page-top' onClick={this.goBannerDetail}>
          <Image className='page-top-image' src={PageTopImage} />
        </View>
        <View className='page-main'>
          <VisitDoctorList data={this.state.DoctorData}></VisitDoctorList>
        </View>
        <View className='page-bottom'>
            <BottomTab tab={this.state.CurrentTab}></BottomTab>
            <Login></Login>
        </View>
      </View>
    )
  }
}



VisitsIndex.defaultProps = {
  data: []
}
